<!DOCTYPE html>
<html>
<head>
    <title>${sysEn}-${pageTitle}</title>
     <#include "/common/com_edit_css.ftl" >
</head>
<body>
    <div class="wrapper wrapper-content fadeInRight commoneditpage">
        <div class="row">
            <div class="col-lg-8 m-auto">
                <div class="ibox ">
                    <div class="ibox-title">
                        <h5>${actNm}-${pageTitle}</h5>
                    </div>
                    <div class="ibox-content">
                        <form id="form" action="${ctx}/store_shop_edit_submit.do" method="post">
                            <input type="hidden" name="id" id="id" value="${obj.id?c}">
                             <input type="hidden" name="type" id="type" value="${obj.type}">
                            <div class="form-group row"><label class="col-lg-2 col-form-label must">${labelTitle}：</label>
                                <div class="col-lg-10">
                                    <input type="text" placeholder=""
                                           value="${obj.name}"
                                           id="name" name="name" class="form-control"
                                           data-message-null="经销商名称并不能为空" />
                                </div>
                            </div>
                         
                             <div class="form-group row">
                                <label class="col-lg-2 col-form-label must">省：</label>
                                <div class="col-lg-10">
                                	<input type="hidden" id="cityCode" value="${obj.city }"/>
                                	<input type="hidden" id="areaCode" value="${obj.area }"/>
                                     <select class="form-control m-b" name="prov" id="prov"  onchange="altCitys()" >
		                            	<option value="">请选择省份...</option>
		                         
		                                <#list areaMap ?keys as key>
		                                   <#if key == obj.prov >
										    <option value=${key} selected="selected">${areaMap[key].name}</option>	
										  <#else>
										  	<option value=${key}>${areaMap[key].name}</option>	
										  </#if>			
										</#list>
	                            	</select>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-lg-2 col-form-label must">市：</label>
                                <div class="col-lg-10">
                                      <select class="form-control m-b" name="city" id="city" onchange="altAreas()">
	       
	                            	  </select>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-lg-2 col-form-label must">区：</label>
                                <div class="col-lg-10">
                                      <select class="form-control m-b" name="area" id="area">
	       
	                            	  </select>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-lg-2 col-form-label must">地址：</label>
                                <div class="col-lg-10">
                                    <input type="text" placeholder="" id="detail"
                                           value="${obj.detail }"
                                           name="detail" 
                                         	data-easyform="null"
                                           class="form-control" />
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-lg-2 col-form-label must">电话：</label>
                                <div class="col-lg-10">
                                    <input type="text" placeholder="" id="tel"
                                           value="${obj.tel }"
                                           name="tel" data-easyform="null"
                                           class="form-control" />
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-lg-2 col-form-label must">经度：</label>
                                <div class="col-lg-10">
                                    <input type="text" placeholder="" id="longitude"
                                           value="${obj.longitude }"
                                           name="longitude" data-easyform="null"
                                           class="form-control" />
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-lg-2 col-form-label must">纬度：</label>
                                <div class="col-lg-10">
                                    <input type="text" placeholder="" id="latitude"
                                           value="${obj.latitude }"
                                           name="latitude" data-easyform="null"
                                           class="form-control" />
                                </div>
                            </div>
                            <div class="form-group row ">
                                <div class="col-lg-offset-2 col-lg-10">
                                    <button class="btn btn-sm btn-primary" type="button" id="signBtn" tg="ensure">确定</button>
                                    <button class="btn btn-sm btn-white" type="button" id="cancelBtn" tg="cancel">取消</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <#include "/common/com_edit_js.ftl">
    <script type="text/javascript">
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
        $(document).ready(function () {
            EditPager.init({
                container:$("#form"),
                param:function () {
                    var id = $("#id").val();
                    return {
                        id:id?id:0,
						name:$("#name").val(),
						prov:$("#prov").val(),
						city:$("#city").val(),
						area:$("#area").val(),
						detail:$("#detail").val(),
						tel:$("#tel").val(),
						type:$("#type").val(),
						longitude:$("#longitude").val(),
						latitude:$("#latitude").val(),
                    };
                }
            });
            
            altCitys($("#cityCode").val());
            altAreas($("#cityCode").val(),$("#areaCode").val());
        });

         function altCitys(code){
			$("#city").html("<option value=''>请选择城市...</option>");
			$("#area").html("<option value=''>请选择区/县...</option&gt;");
			
			var prov = $("#prov").val();
			if(prov!=''){
				$.get("/ajaxGetAreaMap.do",{code:prov,type:"city"},function(data){
					var arr = "";
					var selected = "";
					for(var obj in data.data){
						if(code!=undefined && data.data[obj]["code"]==code){
							selected = "selected='selected'";
						}else{
							selected = "";
						}
						arr += "<option value='"+data.data[obj]["code"]+"' "+selected+">"+data.data[obj]["name"]+"</option>";
					}
					
					$("#city").append(arr);
				},"json");
			}
		}
		
		function altAreas(cityCode,code){
			$("#area").html("<option value=''>请选择区/县...</option>");
			var city = $("#city").val();
			if(cityCode!=undefined){
				city = cityCode;
			}
			var arr = "";
			var selected = "";
			if(city!=''){
				$.get("/ajaxGetAreaMap.do",{code:city,type:"area"},function(data){
					var arr = [];
					var selected = "";
					for(var obj in data.data){
						if(code!=undefined &&  data.data[obj]["code"]==code){
							selected = "selected='selected'";
						}else{
							selected = "";
						}
						arr += "<option value='"+ data.data[obj]["code"]+"' "+selected+">"+ data.data[obj]["name"]+"</option>";
					}
					$("#area").append(arr);
				},"json");
			}
		}
    </script>
</body>
</html>
